#include "GameMode.h"

#include "Config.h"

GameMode::GameMode(const Config& ConfigInstance) : HandlerInstance(ConfigInstance)
{
}

bool GameMode::Run()
{
    bool bGameOver = false;
    bool bFail = false;

    OutputInstance.Clear();

    do
    {
        OutputInstance.PrintMap(HandlerInstance.GetMap());
        
        InputTag Tag = InputInstance.GetInputOnGameRunning();

        HandlerInstance.Updata(Tag, bGameOver, bFail);

        OutputInstance.Clear();
    }
    while (!bGameOver);

    return End(bFail);
}

bool GameMode::End(bool bFail)
{
    OutputInstance.PrintMap(HandlerInstance.GetMap());
    OutputInstance.PrintResult(HandlerInstance.GetMap(), bFail);
    InputTag Tag = InputInstance.GetInputOnGameOver();
    return HandlerInstance.JudgeGameEnd(Tag);
}
